<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>资产信息</title>
    <link rel="stylesheet" type="text/css" href="../../layui/css/layui.css">
    <link rel="stylesheet" type="text/css" href="../../css/sanziguanli/zichanxinxi.css">
    <script type="text/javascript" src="../../layui/layui.js"></script>
    <script src="../../mock/mock/mock-min.js"></script>
    <script src="../../js/jquery-3.4.1.js"></script>
    <script src="../../mock/mock1.js"></script>
    <style>
        .layui-form-selected dl {
            text-align: left;
        }
        
        .hanggao {
            margin: 20px 0px;
        }
    </style>
</head>

<body>
    <div class="layui-contaniner" style="padding: 15px; background-color: #f2f2f2;">
        <div class="layui-head">
            <div class="first second">

                <div class="layui-row">
                    <div class="layui-col-xs1 layui-col-sm1 layui-col-md1 layui-col-lg1 anniu">
                        <button class="layui-btn layui-btn-normal tianjia" lay-event="edit" id="btn1">
                                <i class="layui-icon layui-icon-addition"></i><span>添加</span>
                            </button>
                    </div>
                    <div class="layui-col-xs1 layui-col-sm1 layui-col-md1 layui-col-lg1 anniu">
                        <button class="layui-btn layui-btn-danger shanchucheck" lay-event="del" id="btn2">
                                <i class="layui-icon layui-icon-delete"></i><span>删除</span>
                            </button>
                    </div>
                    <div class="layui-col-xs1 layui-col-sm1 layui-col-md1 layui-col-lg1 anniu">
                        <button class="layui-btn layui-btn-normal" layui-event="" id="btn5" onclick="daochuxuanzhehang()">
                                <svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-arrow-bar-up" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
                                    <path fill-rule="evenodd" d="M8 10a.5.5 0 0 0 .5-.5V3.707l2.146 2.147a.5.5 0 0 0 .708-.708l-3-3a.5.5 0 0 0-.708 0l-3 3a.5.5 0 1 0 .708.708L7.5 3.707V9.5a.5.5 0 0 0 .5.5zm-7 2.5a.5.5 0 0 1 .5-.5h13a.5.5 0 0 1 0 1h-13a.5.5 0 0 1-.5-.5z"/>
                                </svg>
                                <span>导出选中行</span>	
                            </button>
                    </div>
                    <div class="layui-col-xs1 layui-col-sm1 layui-col-md1 layui-col-lg1 anniu" style="margin-left: 35px;">
                        <button class="layui-btn layui-btn-normal" layui-event="" id="btn6" style="display: none;">
                                <svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-arrow-bar-up" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
                                    <path fill-rule="evenodd" d="M8 10a.5.5 0 0 0 .5-.5V3.707l2.146 2.147a.5.5 0 0 0 .708-.708l-3-3a.5.5 0 0 0-.708 0l-3 3a.5.5 0 1 0 .708.708L7.5 3.707V9.5a.5.5 0 0 0 .5.5zm-7 2.5a.5.5 0 0 1 .5-.5h13a.5.5 0 0 1 0 1h-13a.5.5 0 0 1-.5-.5z"/>
                                </svg>
                                <span>导出Excel</span>
                            </button>
                    </div>
                    <div class="layui-col-xs2 layui-col-sm2 layui-col-md2 layui-col-lg2">
                        &nbsp;
                    </div>


                    <div class="layui-col-xs6 layui-col-sm6 layui-col-md6 layui-col-lg6">
                        <form class="layui-form" lay-filter="saixuan">
                            <div class="layui-row">
                                <div class="layui-col-xs3 layui-col-sm3 layui-col-md3 layui-col-lg3">
                                    <select id="qu1" name="areaId" lay-verify="required" lay-filter="qu1">
                                <option value="">地区筛选(区/县)</option>
                            </select>
                                </div>

                                <div class="layui-col-xs3 layui-col-sm3 layui-col-md3 layui-col-lg3">
                                    <select id="zhen1" name="townid" lay-verify="required" name="townId" lay-filter="zhen1">
                                <option value="">地区筛选(镇/街道)</option>
                            </select>
                                </div>

                                <div class="layui-col-xs3 layui-col-sm3 layui-col-md3 layui-col-lg3">
                                    <select name="villageId" lay-verify="required" id="cun1" name="villageId">
                                <option value="">地区筛选(村)</option>
                            </select>
                                </div>

                                <div class="layui-col-xs2 layui-col-sm2 layui-col-md2 layui-col-lg2 ">
                                    <input type="text" name="keyWords" lay-verify="required" placeholder="查询内容或字段" autocomplete="off" class="layui-input chaxun">
                                </div>


                                <div class="layui-col-xs1 layui-col-sm1 layui-col-md1 layui-col-lg1 anniu1">
                                    <button type="button" class="layui-btn layui-btn-normal" onclick="chaxun()" style="margin-left: 60px;">
                            <i class="layui-icon layui-icon-search"></i>&nbsp;&nbsp;查询
                            </button>
                                </div>
                            </div>
                        </form>
                    </div>

                </div>

            </div>
            <div class="layui-footer">
                <table id="demo" lay-filter="test"></table>
                <button type="button" class="layui-btn layui-btn-normal" id="test1">
                    非经营性资产上传<i class="layui-icon">&#xe67c;</i>
                </button>
                <a type="button" class="layui-btn layui-btn-normal" href="http://47.94.152.81:8082/Excel/nonoperatingTemplate
                ">
                    <i class="layui-icon layui-icon-download-circle"></i>&nbsp;&nbsp;非经营性资产下载模板
                </a>
                <button type="button" class="layui-btn " id="test2">
                    经营性资产上传<i class="layui-icon">&#xe67c;</i>
                </button>
                <a type="button" class="layui-btn" href="http://47.94.152.81:8082/Excel/operatingTemplate">
                    <i class="layui-icon layui-icon-download-circle"></i>&nbsp;&nbsp;经营性资产下载模板
                </a>
            </div>
        </div>

        <script type="text/html" id="barDemo">
            <button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="edit">编辑</button>
            <button class="layui-btn layui-btn-xs layui-btn-warm" lay-event="xiangqing">详情</button>
            <button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</button>
        </script>

        <script>
            // 图片上传的文件流
            var tupian = []
                // 图片上传返回的url
            var tupian1 = []
                // 图片上传返回的url
            var wenjian = []
            var element
            var table
            var form
            var laydate
            var option
            var upload
            var layer
            layui.use(['table', 'laydate', 'form', 'element', 'upload'], function() {
                table = layui.table;
                form = layui.form;
                laydate = layui.laydate;
                element = layui.element;
                upload = layui.upload;
                layer = layui.layer;
                jingyingxingzichan()
                feijingyingxingzichan()
                option = {
                    id: 'idTest',
                    url: url + 'assets/query',
                    elem: '#demo',
                    // width: 1300,
                    size: 'lg',
                    limits: [10, 20, 50, 100, 200, 500],
                    page: true,
                    method: 'post',
                    //toolbar: true,
                    skin: 'line',
                    text: {
                        none: '暂无数据' //默认：无数据。
                    },
                    headers: {
                        token: localStorage.getItem('token')
                    },
                    where: {
                        townId: "",
                        villageid: "",
                    },
                    request: {
                        pageName: "currentPage",
                        limitName: "size",
                    },
                    parseData: function(res) {
                        console.log(res)
                        if (res.code == 401) {

                            window.parent.window.location.href = "../login/index.html"
                        } else {
                            //res 即为原始返回的数据
                            return {
                                code: 0, //解析接口状态
                                msg: res.msg, //解析提示文本
                                count: res.data.count, //解析数据长度
                                data: setdata(res.data.AssetsDTOList), //解析数据列表
                            };
                        }


                    },
                    cols: [
                        [{
                            field: 'checkbox',
                            type: 'checkbox',
                            width: 100,
                            align: 'center'
                        }, {
                            field: 'number',
                            title: '序号',
                            width: 100,
                            align: 'center',
                            type: 'numbers'
                        }, {
                            field: 'villagename',
                            title: '村名',
                            width: 200,
                            align: 'center',
                        }, {
                            field: 'assetsname',
                            title: '资产名称',
                            width: 300,
                            align: 'center',
                            sort: true
                        }, {
                            field: 'assetstype',
                            title: '资产类型',
                            width: 200,
                            align: 'center',
                            sort: true
                        }, {
                            field: 'operation',
                            title: '操作',
                            align: 'center',
                            toolbar: '#barDemo'
                        }]
                    ]
                };
                tableIns = table.render(option);
                areas.forEach(item => {
                    // console.log($('#zhen1')[0].innerHTML)
                    $('#qu1')[0].innerHTML += ` <option value="` + item.id + `">` + item.name + `</option>`
                })
                towns.forEach(item => {
                        // console.log($('#zhen1')[0].innerHTML)
                        $('#zhen1')[0].innerHTML += ` <option value="` + item.id + `">` + item.name + `</option>`
                    })
                    //镇生成
                form.on('select(qu1)', function(data) {
                    $('#zhen1').empty()
                    $('#zhen1')[0].innerHTML += ` <option value="">地区筛选(镇/街道)</option>`
                    villages.forEach(item => {
                        if (item.areaId == data.value) {
                            $('#zhen1')[0].innerHTML += ` <option value="` + item.id + `">` + item.name + `</option>`
                        }
                    })
                    form.render('select', "saixuan")
                });
                // 村生成
                form.on('select(zhen1)', function(data) {
                    $('#cun1').empty()
                    $('#cun1')[0].innerHTML += ` <option value="">地区筛选(村)</option>`
                    villages.forEach(item => {
                        if (item.townId == data.value) {
                            $('#cun1')[0].innerHTML += ` <option value="` + item.id + `">` + item.name + `</option>`
                        }
                    })
                    form.render('select', "saixuan")
                });
                form.render('select', "saixuan")

                table.on('tool(test)', function(obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
                    var data = obj.data; //获得当前行数据
                    var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
                    var tr = obj.tr; //获得当前行 tr 的 DOM 对象（如果有的话）
                    console.log(obj)
                        //删除行
                    if (layEvent === 'del') {
                        layer.open({
                            title: '温馨提示',
                            type: '0',
                            area: ['400px', '160px'],
                            offset: 'auto',
                            content: '<div><p>你确定要删除选中项吗</p></div>',
                            btn: ['取消', '确认'],
                            btn2: function() {
                                var data = {};
                                data.IdList = [];
                                data.IdList.push(obj.data.assets.id)
                                traditional: true, //防止深度序列化
                                    console.log(data)
                                $.ajax({
                                    url: url + "assets/del",
                                    method: "post",
                                    traditional: true, //防止深度序列化
                                    data: data,
                                    success: function(data) {
                                        console.log(data);
                                        if (data.code === 200) {

                                            table.reload("idTest", option);
                                            layer.msg('删除成功!')
                                        } else {
                                            layer.msg(data.msg)
                                        }
                                    },
                                    error: function(err) {
                                        layer.msg('删除失败!')
                                    },
                                });
                                layer.closeAll();
                            },
                            btn1: function() {
                                layer.msg('已取消操作')
                            },
                        });
                    }

                    //详情信息    		
                    if (layEvent === 'xiangqing') {
                        layer.open({
                            type: 1,
                            title: "详细信息",
                            offset: "auto",
                            content: `
                        <div class="layui-row">
                    <div class="layui-col-xs4 layui-col-sm4 layui-col-md4 hanggao">
                        <label class="layui-form-label xiangqingtitle">资产名称</label>
                        <label class="layui-form-label xiangqingcontent" style="margin-left:-40px;">` + obj.data.assetsname + `</label>
                    </div>
                    <div class="layui-col-xs4 layui-col-sm4 layui-col-md4 hanggao">
                        <label class="layui-form-label xiangqingtitle">资产类型</label>
                        <label class="layui-form-label xiangqingcontent" style="margin-left:-40px;">` + obj.data.assetstype + `</label>
                    </div>
                    <div class="layui-col-xs4 layui-col-sm4 layui-col-md4 hanggao">
                        <label class="layui-form-label xiangqingtitle">所属村</label>
                        <label class="layui-form-label xiangqingcontent" style="margin-left:-70px;">` + obj.data.villagename + `</label>
                    </div>
                    <div class="layui-col-xs4 layui-col-sm4 layui-col-md4 hanggao">
                        <label class="layui-form-label xiangqingtitle">所属组</label>
                        <label class="layui-form-label xiangqingcontent zu">` + obj.data.groupId + `</label>
                    </div>
                    <div class="layui-col-xs4 layui-col-sm4 layui-col-md4 hanggao">
                        <label class="layui-form-label xiangqingtitle">所属街道</label>
                        <label class="layui-form-label xiangqingcontent" style="margin-left:-50px;">` + gettown(obj.data.assets.townId).name + `</label>
                    </div>
                   	 	</div>

                        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                            <ul class="layui-tab-title">
                                <li class="layui-this">非经营性资产</li>
                                <li>经营性资产</li>
                            </ul>
                            
                            <div class="layui-tab-content">
                                <div class="layui-tab-item layui-show">
                                <div class="layui-row">
                                    <div class="layui-col-xs4 layui-col-sm4 layui-col-md4 hanggao">
                                        <label class="layui-form-label xiangqingtitle">计量单位</label>
                                        <label class="layui-form-label xiangqingcontent wei" style="margin-left:-80px;">` + obj.data.nonOperatingAssets.unitOfMeasurement + `</label>
                                    </div>
                                    <div class="layui-col-xs4 layui-col-sm4 layui-col-md4 hanggao">
                                        <label class="layui-form-label xiangqingtitle">单价</label>
                                        <label class="layui-form-label xiangqingcontent jia" style="margin-left:-80px;">` + obj.data.nonOperatingAssets.unitPrice + `</label>
                                    </div>
                                    <div class="layui-col-xs4 layui-col-sm4 layui-col-md4  hanggao">
                                        <label class="layui-form-label xiangqingtitle">现今价值</label>
                                        <label class="layui-form-label xiangqingcontent jiazhi" style="margin-left:-75px;">` + obj.data.nonOperatingAssets.presentValue + `</label>
                                    </div>
                                    <div class="layui-col-xs4 layui-col-sm4 layui-col-md4 hanggao">
                                        <label class="layui-form-label xiangqingtitle">规格型号</label>
                                        <label class="layui-form-label xiangqingcontent xinghao" style="margin-left:-80px;">` + obj.data.nonOperatingAssets.sizeAndModel + `</label>
                                    </div>
                                    <div class="layui-col-xs4 layui-col-sm4 layui-col-md4 hanggao">
                                        <label class="layui-form-label xiangqingtitle">产品来源</label>
                                        <label class="layui-form-label xiangqingcontent laiyuan" style="margin-left:-80px;">` + obj.data.nonOperatingAssets.source + `</label>
                                    </div>
                                    <div class="layui-col-xs4 layui-col-sm4 layui-col-md4 hanggao">
                                        <label class="layui-form-label xiangqingtitle">使用部门</label>
                                        <label class="layui-form-label xiangqingcontent bumen" style="margin-left:-35px;">` + obj.data.nonOperatingAssets.useDepartmentsAndUser + `</label>
                                    </div>
                                    <div class="layui-col-xs4 layui-col-sm4 layui-col-md4 hanggao">
                                        <label class="layui-form-label xiangqingtitle">产品状态</label>
                                        <label class="layui-form-label xiangqingcontent zhuangtai" style="margin-left:-80px;">` + obj.data.nonOperatingAssets.productStatus + `</label>
                                    </div>
                                    <div class="layui-col-xs4 layui-col-sm4 layui-col-md4 hanggao">
                                        <label class="layui-form-label xiangqingtitle">数量</label>
                                        <label class="layui-form-label xiangqingcontent shuliang" style="margin-left:-70px;">` + obj.data.nonOperatingAssets.quantity + `</label>
                                    </div>
                                    <div class="layui-col-xs4 layui-col-sm4 layui-col-md4 hanggao">
                                        <label class="layui-form-label xiangqingtitle">变动情况</label>
                                        <label class="layui-form-label xiangqingcontent qingkuang" style="margin-left:-80px;">` + obj.data.nonOperatingAssets.changes + `</label>
                                    </div>
                                    <div class="layui-col-xs4 layui-col-sm4 layui-col-md4 hanggao">
                                        <label class="layui-form-label xiangqingtitle">品牌</label>
                                        <label class="layui-form-label xiangqingcontent pinpai" style="margin-left:-50px;">` + obj.data.nonOperatingAssets.brand + `</label>
                                    </div>
                                    <div class="layui-col-xs4 layui-col-sm4 layui-col-md4 hanggao">
                                        <label class="layui-form-label xiangqingtitle">构建时间</label>
                                        <label class="layui-form-label xiangqingcontent shijian" style="margin-left:-35px;">` + obj.data.nonOperatingAssets.creationTime + `</label>
                                    </div>
                                    <div class="layui-col-xs4 layui-col-sm4 layui-col-md4 hanggao">
                                        <label class="layui-form-label xiangqingtitle">预计年限</label>
                                        <label class="layui-form-label xiangqingcontent nianxian" style="margin-left:-80px;">` + obj.data.nonOperatingAssets.estimatedYears + `</label>
                                    </div>
                                </div>
                                </div>

                                <div class="layui-tab-item">
                                <div class="layui-row">
                                    <div class="layui-col-xs5 layui-col-sm5 layui-col-md5 hanggao">
                                        <label class="layui-form-label xiangqingtitle">承租方</label>
                                        <label class="layui-form-label xiangqingcontent zufang" style="margin-left:-90px;">` + obj.data.operatingAssets.lessee + `</label>
                                    </div>
                                    <div class="layui-col-xs7 layui-col-sm7 layui-col-md7 hanggao">
                                        <label class="layui-form-label xiangqingtitle">合同期限</label>
                                        <label class="layui-form-label xiangqingcontent qixian" style="margin-left:-60px;">` + obj.data.operatingAssets.durationOfCooperation + `</label>
                                    </div>
                                    <div class="layui-col-xs6 layui-col-sm6 layui-col-md6 hanggao">
                                        <label class="layui-form-label xiangqingtitle">合同状态</label>
                                        <label class="layui-form-label xiangqingcontent hetongzhuangtai" style="margin-left:-80px;">` + obj.data.operatingAssets.contractStatus + `</label>
                                    </div>
                                    <div class="layui-col-xs6 layui-col-sm6 layui-col-md6 hanggao">
                                        <label class="layui-form-label xiangqingtitle">签订合同</label>
                                        <label class="layui-form-label xiangqingcontent tong" style="margin-left:-100px;">` + obj.data.operatingAssets.contractSigned + `</label>
                                    </div>
                                    <div class="layui-col-xs6 layui-col-sm6 layui-col-md6 hanggao">
                                        <label class="layui-form-label xiangqingtitle">支付情况</label>
                                        <label class="layui-form-label xiangqingcontent zhifuqingkuang" style="margin-left:-60px;">` + obj.data.operatingAssets.paymentStatus + `</label>
                                    </div>
                                    <div class="layui-col-xs6 layui-col-sm6 layui-col-md6 hanggao">
                                        <label class="layui-form-label xiangqingtitle">合同金额</label>
                                        <label class="layui-form-label xiangqingcontent hetongjine" style="margin-left:-100px;">` + obj.data.operatingAssets.amount + `</label>
                                    </div>
                                    <div class="layui-col-xs6 layui-col-sm6 layui-col-md6 hanggao">
                                        <label class="layui-form-label xiangqingtitle">备注</label>
                                        <label class="layui-form-label xiangqingcontent remarks" style="margin-left:-60px;">` + obj.data.operatingAssets.remarks + `</label>
                                    </div>
                                </div>
                                </div>
                            </div>
                        </div>
                        `,
                            area: ["1000px", "800px"],
                            btn: ['确定', ], //可以无限个按钮
                            btnAlign: "c",
                            btn1: function() {
                                layer.closeAll();
                            },
                            success: function() {
                                if (obj.data.assets.groupId == null) {
                                    $(".zu")[0].innerHTML = ""
                                } else {
                                    $(".zu")[0].innerHTML = getgroup(obj.data.assets.groupId).name
                                }
                                if (obj.data.operatingAssets.contractSigned == 0) {
                                    $(".tong")[0].innerHTML = '否'
                                } else if (obj.data.operatingAssets.contractSigned == 1) {
                                    $(".tong")[0].innerHTML = '是'
                                } else {
                                    $(".tong")[0].innerHTML = ''
                                }
                                if (obj.data.nonOperatingAssets.unitOfMeasurement == null) {
                                    $(".wei")[0].innerHTML = ""
                                } else {
                                    $(".wei")[0].innerHTML = obj.data.nonOperatingAssets.unitOfMeasurement
                                }
                                if (obj.data.nonOperatingAssets.unitPrice == null) {
                                    $(".jia")[0].innerHTML = ""
                                } else {
                                    $(".jia")[0].innerHTML = obj.data.nonOperatingAssets.unitPrice
                                }
                                if (obj.data.nonOperatingAssets.presentValue == null) {
                                    $(".jiazhi")[0].innerHTML = ""
                                } else {
                                    $(".jiazhi")[0].innerHTML = obj.data.nonOperatingAssets.presentValue
                                }
                                if (obj.data.nonOperatingAssets.sizeAndModel == null) {
                                    $(".xinghao")[0].innerHTML = ""
                                } else {
                                    $(".xinghao")[0].innerHTML = obj.data.nonOperatingAssets.sizeAndModel
                                }
                                if (obj.data.nonOperatingAssets.source == null) {
                                    $(".laiyuan")[0].innerHTML = ""
                                } else {
                                    $(".laiyuan")[0].innerHTML = obj.data.nonOperatingAssets.source
                                }
                                if (obj.data.nonOperatingAssets.useDepartmentsAndUser == null) {
                                    $(".bumen")[0].innerHTML = ""
                                } else {
                                    $(".bumen")[0].innerHTML = obj.data.nonOperatingAssets.useDepartmentsAndUser
                                }
                                if (obj.data.nonOperatingAssets.productStatus == null) {
                                    $(".zhuangtai")[0].innerHTML = ""
                                } else {
                                    $(".zhuangtai")[0].innerHTML = obj.data.nonOperatingAssets.productStatus
                                }
                                if (obj.data.nonOperatingAssets.quantity == null) {
                                    $(".shuliang")[0].innerHTML = ""
                                } else {
                                    $(".shuliang")[0].innerHTML = obj.data.nonOperatingAssets.quantity
                                }
                                if (obj.data.nonOperatingAssets.changes == null) {
                                    $(".qingkuang")[0].innerHTML = ""
                                } else {
                                    $(".qingkuang")[0].innerHTML = obj.data.nonOperatingAssets.changes
                                }
                                if (obj.data.nonOperatingAssets.brand == null) {
                                    $(".pinpai")[0].innerHTML = ""
                                } else {
                                    $(".pinpai")[0].innerHTML = obj.data.nonOperatingAssets.brand
                                }
                                if (obj.data.nonOperatingAssets.creationTime == null) {
                                    $(".shijian")[0].innerHTML = ""
                                } else {
                                    $(".shijian")[0].innerHTML = obj.data.nonOperatingAssets.creationTime
                                }
                                if (obj.data.nonOperatingAssets.estimatedYears == null) {
                                    $(".nianxian")[0].innerHTML = ""
                                } else {
                                    $(".nianxian")[0].innerHTML = obj.data.nonOperatingAssets.estimatedYears
                                }
                                if (obj.data.operatingAssets.lessee == null) {
                                    $(".zufang")[0].innerHTML = ""
                                } else {
                                    $(".zufang")[0].innerHTML = obj.data.operatingAssets.lessee
                                }
                                if (obj.data.operatingAssets.durationOfCooperation == null) {
                                    $(".qixian")[0].innerHTML = ""
                                } else {
                                    $(".qixian")[0].innerHTML = obj.data.operatingAssets.durationOfCooperation
                                }
                                if (obj.data.operatingAssets.contractStatus == null) {
                                    $(".hetongzhuangtai")[0].innerHTML = ""
                                } else {
                                    $(".hetongzhuangtai")[0].innerHTML = obj.data.operatingAssets.contractStatus
                                }
                                if (obj.data.operatingAssets.paymentStatus == null) {
                                    $(".zhifuqingkuang")[0].innerHTML = ""
                                } else {
                                    $(".zhifuqingkuang")[0].innerHTML = obj.data.operatingAssets.paymentStatus
                                }
                                if (obj.data.operatingAssets.amount == null) {
                                    $(".hetongjine")[0].innerHTML = ""
                                } else {
                                    $(".hetongjine")[0].innerHTML = obj.data.operatingAssets.amount
                                }
                                if (obj.data.operatingAssets.remarks == null) {
                                    $(".remarks")[0].innerHTML = ""
                                } else {
                                    $(".remarks")[0].innerHTML = obj.data.operatingAssets.remarks
                                }
                            }
                        });
                    };

                    //编辑信息
                    if (layEvent === 'edit') {
                        layer.open({
                            type: 1,
                            title: "资产编辑",
                            offset: "auto",
                            area: ['800px', '660px'],
                            content: `
                        <div class="layui-tab">
                            <ul class="layui-tab-title">
                                <li class="layui-this">资源编辑</li>
                                <li>非经营性资产</li>
                                <li>经营性资产</li>
                            </ul>
                          <div class="layui-tab-content">

                            <div class="layui-tab-item layui-show">
                                <div class="juzhong">
                                    <form class="layui-form xingzhengcunxinxitianjia" id="assets" lay-filter="assets" action="">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">所属区</label>
                                        <div class="layui-input-block">
                                            <select id="qu" name="areaId" lay-verify="required" lay-filter="qu">
                                                <option value="">请选择所属区</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">所属镇</label>
                                        <div class="layui-input-block">
                                            <select id="zhen" name="townId" lay-verify="required" lay-filter="zhen">
                                                <option value="">请选择所属镇</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">所属村</label>
                                        <div class="layui-input-block">
                                            <select id="cun" name="villageId" lay-verify="required" lay-filter="cun">
                                                <option value="">请选择所属村</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">所属组</label>
                                        <div class="layui-input-block">
                                            <select id="zu" name="groupId" lay-verify="required" lay-filter="zu">
                                                <option value="">请选择所属组</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">资产类型</label>
                                        <div class="layui-input-block">
                                            <select id="zichanleixing" name="typeId" lay-verify="required" lay-filter="zichanleixing">
                                                <option value="">请选择资产类型</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">名称</label>
                                        <div class="layui-input-block">
                                            <input type="text"  value="` + obj.data.assetsname + `" lay-filter="ziyuanxinxi" name="name" required lay-verify="required" placeholder="请输入资产名称" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>                                                                                                 
                                </form>
                                </div>
                            </div>

                            <div class="layui-tab-item">
                             <form class="layui-form xingzhengcunxinxitianjia" id="nonOperatingAssets" lay-filter="nonOperatingAssets" action="">
                                <div class="layui-container">  
                                    <div class="layui-row">
                                      <div class="layui-col-xs6  layui-col-md6">
                                        <div class="layui-form-item">
                                        <label class="layui-form-label">计量单位</label>
                                        <div class="layui-input-block">
                                          <input type="text" name="unitOfMeasurement" required  lay-verify="required" autocomplete="off" class="layui-input" style="width:275px;">
                                        </div>
                                        </div>
                                      </div>
                                      <div class="layui-col-xs6  layui-col-md6">
                                        <div class="layui-form-item" style="margin-left:-200px;">
                                        <label class="layui-form-label" >数量</label>
                                        <div class="layui-input-block">
                                          <input type="number" name="quantity" required  lay-verify="number" autocomplete="off" class="layui-input" style="width:275px;">
                                        </div>
                                        </div>
                                      </div>
                                       <div class="layui-col-xs6 layui-col-md6">
                                        <div class="layui-form-item">
                                        <label class="layui-form-label">单价</label>
                                        <div class="layui-input-block">
                                          <input type="number" name="unitPrice" required  lay-verify="number" autocomplete="off" class="layui-input" style="width:275px;">
                                        </div>
                                        </div>
                                      </div>
                                      <div class="layui-col-xs6 layui-col-md6">
                                        <div class="layui-form-item" style="margin-left:-200px;">
                                        <label class="layui-form-label">变动情况</label>
                                        <div class="layui-input-block">
                                          <input type="text" name="changes" required  lay-verify="required" autocomplete="off" class="layui-input" style="width:275px;">
                                        </div>
                                        </div>
                                      </div>
                                       <div class="layui-col-xs6 layui-col-md6">
                                        <div class="layui-form-item">
                                        <label class="layui-form-label">现今价值</label>
                                        <div class="layui-input-block">
                                          <input type="number" name="presentValue" required  lay-verify="number" autocomplete="off" class="layui-input" style="width:275px;">
                                        </div>
                                        </div>
                                      </div>
                                      <div class="layui-col-xs6 layui-col-md6">
                                        <div class="layui-form-item" style="margin-left:-200px;">
                                        <label class="layui-form-label">品牌</label>
                                        <div class="layui-input-block">
                                          <input type="text" name="brand" required  lay-verify="required" autocomplete="off" class="layui-input" style="width:275px;">
                                        </div>
                                        </div>
                                      </div>
                                       <div class="layui-col-xs6 layui-col-md6">
                                        <div class="layui-form-item">
                                        <label class="layui-form-label">规格型号</label>
                                        <div class="layui-input-block">
                                          <input type="text" name="sizeAndModel" required  lay-verify="required" autocomplete="off" class="layui-input" style="width:275px;">
                                        </div>
                                        </div>
                                      </div>
                                      <div class="layui-col-xs6 layui-col-md6">
                                        <div class="layui-form-item" style="margin-left:-200px;">
                                        <label class="layui-form-label">构建时间</label>
                                        <div class="layui-input-block">
                                          <input type="text" name="creationTime" id="goujianshijian" value="` + obj.data.nonOperatingAssets.creationTime + `" required  lay-verify="date" autocomplete="off" class="layui-input" style="width:275px;">
                                        </div>
                                        </div>
                                      </div>
                                       <div class="layui-col-xs6 layui-col-md6">
                                        <div class="layui-form-item">
                                        <label class="layui-form-label">产品来源</label>
                                        <div class="layui-input-block">
                                          <input type="text" name="source" required  lay-verify="required" autocomplete="off" class="layui-input" style="width:275px;">
                                        </div>
                                        </div>
                                      </div>
                                      <div class="layui-col-xs6  layui-col-md6">
                                        <div class="layui-form-item" style="margin-left:-200px;">
                                        <label class="layui-form-label">预计年限</label>
                                        <div class="layui-input-block">
                                          <input type="text" name="estimatedYears" required  lay-verify="required" autocomplete="off" class="layui-input" style="width:275px;">
                                        </div>
                                        </div>
                                      </div>
                                       <div class="layui-col-xs6 layui-col-md6">
                                        <div class="layui-form-item">
                                        <label class="layui-form-label">使用部门</label>
                                        <div class="layui-input-block">
                                          <input type="text" name="useDepartmentsAndUser" required  lay-verify="required" autocomplete="off" class="layui-input" style="width:275px;">
                                        </div>
                                        </div>
                                      </div>
                                      <div class="layui-col-xs6 layui-col-md6">
                                        <div class="layui-form-item" style="margin-left:-200px;">
                                        <label class="layui-form-label">产品状态</label>
                                        <div class="layui-input-block">
                                          <input type="text" name="productStatus" required  lay-verify="required" autocomplete="off" class="layui-input" style="width:275px;">
                                        </div>
                                        </div>
                                      </div>
                                      <div class="layui-form-item layui-form-text">
                                        <label class="layui-form-label">备注</label>
                                        <div class="layui-input-block">
                                          <textarea name="remarks" placeholder="请输入备注信息" class="layui-textarea beizhu" style="width:275px;"></textarea>
                                        </div>
                                      </div>
                                    </div>
                                </div>
                                </form>
                            </div>

                            <div class="layui-tab-item">
                              <form class="layui-form xingzhengcunxinxitianjia" id="operatingAssets" lay-filter="operatingAssets" action="" >
                                <div class="layui-container">  
                                    <div class="layui-row">
                                        <div class="layui-col-xs6  layui-col-md6">
                                            <div class="layui-form-item">
                                            <label class="layui-form-label">承租方</label>
                                            <div class="layui-input-block">
                                            <input type="text" name="lessee" required  lay-verify="required" autocomplete="off" class="layui-input" style="width:275px;">
                                            </div>
                                            </div>
                                        </div>
                                        <div class="layui-col-xs6  layui-col-md6">
                                            <div class="layui-form-item" style="margin-left:-200px;">
                                            <label class="layui-form-label">签订合同</label>
                                            <div class="layui-input-block">
                                            <select name="contractSigned" lay-verify="required">
                                                <option value="">请选择是否签订合同</option>
                                                <option value="0">是</option>
                                                <option value="1">否</option>
                                            </select>
                                            </div>
                                            </div>
                                        </div>
                                        <div class="layui-col-xs6 layui-col-md6">
                                            <div class="layui-form-item">
                                            <label class="layui-form-label">合同期限</label>
                                            <div class="layui-input-block">
                                            <input type="text" name="durationOfCooperation" required  lay-verify="required" autocomplete="off" class="layui-input" style="width:275px;">
                                            </div>
                                            </div>
                                        </div>
                                        <div class="layui-col-xs6 layui-col-md6">
                                            <div class="layui-form-item" style="margin-left:-200px;">
                                            <label class="layui-form-label">支付情况</label>
                                            <div class="layui-input-block">
                                            <input type="text" name="paymentStatus" required  lay-verify="required" autocomplete="off" class="layui-input" style="width:275px;">
                                            </div>
                                            </div>
                                        </div>
                                        <div class="layui-col-xs6 layui-col-md6">
                                            <div class="layui-form-item">
                                            <label class="layui-form-label">合同状态</label>
                                            <div class="layui-input-block">
                                            <input type="text" name="contractStatus" required  lay-verify="required" autocomplete="off" class="layui-input" style="width:275px;">
                                            </div>
                                            </div>
                                        </div>
                                        <div class="layui-col-xs6 layui-col-md6">
                                            <div class="layui-form-item" style="margin-left:-200px;">
                                            <label class="layui-form-label">合同金额</label>
                                            <div class="layui-input-block">
                                            <input type="text" name="amount" required  lay-verify="required" autocomplete="off" class="layui-input" style="width:275px;">
                                            </div>
                                            </div>
                                        </div>                                                         
                                        <div class="layui-form-item layui-form-text">
                                            <label class="layui-form-label">备注</label>
                                            <div class="layui-input-block">
                                            <textarea name="remarks" placeholder="请输入备注信息" class="layui-textarea beizhu" style="width:275px;"></textarea>
                                            </div>
                                        </div>
                                        <div class="layui-form-item" style="display:none;">
                                            <label class="layui-form-label">图片</label>
                                            <div class="layui-input-block">
                                                <div class="layui-upload" name="">
                                                    <div class="layui-upload" name="">
                                                        <button type="button" class="layui-btn" id="shangchuantupian">图片选择</button>
                                                        <button type="button" class="layui-btn" id="shangchuananniu">图片上传</button>
                                                        <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                                            预览图：
                                                            <div class="layui-upload-list" id="tupianyuelan"></div>
                                                        </blockquote>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="layui-form-item" style="display:none;">
                            <label class="layui-form-label">相关文件</label>
                            <div class="layui-input-block">
                                <div class="layui-upload-drag" id="test3">
                                    <i class="layui-icon"></i>
                                    <p>点击上传，或将文件拖拽到此处</p>
                                    <div class="layui-hide" id="uploadDemoView">
                                        <hr>
                                        <p/>
                                    </div>
                                </div>
                                <button type="button" class="layui-btn" id="testListAction">点击上传</button>
                            </div>
                          </div>   
                                    </div>
                                </div>
                              </form>
                            </div>
                          </div>
                        </div>`,
                            success: function() {
                                // if (data.operatingAssets.image !== undefined) {
                                //     // 将图片赋空  然后赋值
                                //     tupian = []
                                //     tupian1 = []
                                //     var cunmaotu0 = JSON.parse(data.operatingAssets.image)
                                //     tupian1 = cunmaotu0
                                //     console.log(tupian1)
                                //     if (cunmaotu0 !== null && cunmaotu0.length !== 0) {
                                //         cunmaotu0.forEach((item, index) => {
                                //             $('#tupianyuelan').append(`<img onclick=quchutupian("` + item.url + `",this) src=" ` + item.url + `" class="layui-upload-img">`)
                                //         })
                                //     }
                                // }

                                // if (data.operatingAssets.file == null) {
                                //     wenjian = []
                                // } else {
                                //     wenjian = JSON.parse(data.operatingAssets.file)

                                //     layui.$('#test3').find('p')[0].innerHTML = "点击更换"
                                //     layui.$('#uploadDemoView').removeClass('layui-hide').find('p')[0].innerHTML = wenjian[0].name
                                // }
                                areas.forEach(item => {
                                    $('#qu')[0].innerHTML += `<option value="` + item.id + `">` + item.name + `</option>`
                                })
                                towns.forEach(item => {
                                    $('#zhen')[0].innerHTML += ` <option value="` + item.id + `">` + item.name + `</option>`
                                })
                                villages.forEach(item => {
                                    $('#cun')[0].innerHTML += ` <option value="` + item.id + `">` + item.name + `</option>`
                                })

                                // 监听每一个选择框的选择事件;
                                var bianjiqu = ""
                                form.on('select(qu)', function(data) {
                                    bianjiqu = data.value
                                    $('#zhen').empty()
                                    $('#zhen')[0].innerHTML += ` <option value="">请选择所属村</option>`
                                    towns.forEach(item => {
                                        if (item.areaId == data.value) {
                                            $('#zhen')[0].innerHTML += ` <option value="` + item.id + `">` + item.name + `</option>`
                                        }
                                    })
                                    form.render('select', "assets")
                                });
                                // 2.镇监听
                                form.on('select(zhen)', function(data) {
                                    $('#cun').empty()
                                    $('#cun')[0].innerHTML += ` <option value="">请选择所属村</option>`
                                    villages.forEach(item => {
                                        if (item.townId == data.value) {
                                            $('#cun')[0].innerHTML += ` <option value="` + item.id + `">` + item.name + `</option>`
                                        }
                                    })
                                    form.render('select', "assets")
                                });
                                // 村监听 
                                form.on('select(cun)', function(data) {
                                    $('#zu').empty()
                                    $('#zu')[0].innerHTML += ` <option value="">请选择所属组</option>`

                                    if (data.value != "") {
                                        // 为组进行赋值
                                        var data1 = {}
                                        console.log(getvillage(data.value))
                                        data1.areaId = bianjiqu
                                        data1.townId = getvillage(data.value).townId
                                        data1.villageId = data.value
                                        console.log(data1)
                                        $.ajax({
                                            url: url + "group/querygroup",
                                            method: "get",
                                            data: data1,
                                            success: function(data) {
                                                console.log(data)
                                                data.data.group.forEach(item => {
                                                    $('#zu')[0].innerHTML += ` <option value="` + item.id + `">` + item.name + `</option>`
                                                })
                                                form.render('select', "assets")
                                            },
                                            error: function(err) {
                                                console.log(err)
                                            }
                                        })

                                        $.ajax({
                                            url: url + "assetstype/query",
                                            method: "post",
                                            data: data1,
                                            success: function(data) {
                                                console.log(data)
                                                data.data.AssetsTypeList.forEach(item => {
                                                    $('#zichanleixing')[0].innerHTML += ` <option value="` + item.id + `">` + item.name + `</option>`
                                                })
                                                form.render('select', "assets")
                                            },
                                            error: function(err) {
                                                console.log(err)
                                            }
                                        })

                                    }

                                })
                                $('#qu').val(obj.data.assets.areaId);
                                $('#zhen').val(obj.data.assets.townId);
                                $('#cun').val(obj.data.assets.villageId);
                                $('#zichanleixing').val(obj.data.assets.typeId);
                                form.render('select', "assets")
                                form.render('select', "operatingAssets")
                                    // 组赋值
                                var datatype = {}
                                datatype.areaId = bianjiqu
                                datatype.villageId = obj.data.assets.villageId
                                datatype.townId = obj.data.assets.townId
                                $.ajax({
                                        url: url + "group/querygroup",
                                        method: "get",
                                        data: datatype,
                                        success: function(data) {
                                            console.log(data)
                                            data.data.group.forEach(item => {
                                                $('#zu')[0].innerHTML += ` <option value="` + item.id + `">` + item.name + `</option>`
                                            })
                                            $('#zu').val(obj.data.assets.groupId);
                                            form.render('select', "assets")
                                        },
                                        error: function(err) {
                                            console.log(err)
                                        }
                                    })
                                    // datatype.currentPage = 1
                                    // datatype.size = 1000
                                $.ajax({
                                    url: url + "assetstype/query",
                                    method: "post",
                                    data: datatype,
                                    success: function(data) {
                                        console.log(data)
                                        data.data.AssetsTypeList.forEach(item => {
                                            $('#zichanleixing')[0].innerHTML += ` <option value="` + item.id + `">` + item.name + `</option>`
                                        })
                                        $('#zichanleixing').val(obj.data.assetsType.id);
                                        form.render('select', "assets")
                                    },
                                    error: function(err) {
                                        console.log(err)
                                    }
                                })

                                laydate.render({
                                    elem: '#goujianshijian' //指定元素
                                });
                                // 图片上��
                                // upload.render({
                                //     elem: '#shangchuantupian',
                                //     url: url + 'upload',
                                //     name: "files",
                                //     data: {
                                //         folderName: "ZiChanJingYing"
                                //     },
                                //     headers: {
                                //         token: localStorage.getItem('token')
                                //     },
                                //     field: "multipartFiles",
                                //     auto: false,
                                //     bindAction: "#shangchuananniu",
                                //     multiple: true,
                                //     before: function(obj) { //obj参数包含的信息，跟 choose回调完全一致，可参见上文。
                                //         loading2 = layer.load(); //换了种风格
                                //     },
                                //     allDone: function(obj) { //当文件全部被提交后，才触发
                                //         layer.close(loading2);
                                //         layer.msg('上传成功')
                                //     },
                                //     choose: function(obj) {
                                //         var files = obj.pushFile();
                                //         console.log(files)
                                //         console.log(obj)
                                //             //预读本地文件示例，不支持ie8
                                //         obj.preview(function(index, file, result) {
                                //             tupian.push(file)
                                //             $('#tupianyuelan').append('<img src="' + result + '" alt="' + file.name + '" class="layui-upload-img">')
                                //         });
                                //     },
                                //     done: function(res, index, upload) {
                                //         res.data = JSON.parse(res.data)
                                //         console.log(res)
                                //         if (res.code === 200) {
                                //             res.data.forEach(item => {
                                //                 tupian1.push({
                                //                     name: item.name,
                                //                     url: item.url
                                //                 })
                                //             })
                                //         }
                                //     },
                                //     error: function(index, upload) {
                                //         layer.msg("上传失败")
                                //             //当上传失败时，你可以生成一个“重新上传”的按钮，点击该按钮时，执行 upload() 方法即可实现重新上传
                                //     },

                                // })
                                // form.render('select', "bianji")

                                //拖拽上传
                                // upload.render({
                                //     elem: '#test3',
                                //     url: url + 'upload', //改成您自己的上传接口
                                //     accept: 'file',
                                //     auto: false,
                                //     field: "multipartFiles",
                                //     bindAction: '#testListActio',
                                //     before: function(obj) { //obj参数包含的信息，跟 choose回调完全一致，可参见上文。
                                //         loading2 = layer.load(); //换了种风格
                                //     },
                                //     choose: function(res) {
                                //         res.preview(function(index, file, result) {
                                //             layui.$('#test3').find('p')[0].innerHTML = "点击更换"
                                //             layui.$('#uploadDemoView').removeClass('layui-hide').find('p')[0].innerHTML = file.name
                                //         });
                                //     },
                                //     done: function(res, index, upload) {
                                //         layer.close(loading2);
                                //         res.data = JSON.parse(res.data)
                                //         console.log(res)
                                //         if (res.code === 200) {
                                //             wenjian = res.data
                                //         } else {
                                //             layer.msg('上传失败')
                                //         }
                                //     }
                                // });
                                form.render('select', "bianji")
                            },
                            btn: ['提交'], //可以无限个按钮
                            btnAlign: "c",
                            btn1: function() {
                                var data = {}
                                data.assets = form.val("assets");
                                data.nonOperatingAssets = form.val("nonOperatingAssets");
                                data.operatingAssets = form.val("operatingAssets");

                                data = JSON.stringify(data)

                                // if (tupian1.length !== 0) {
                                //     data.operatingAssets.image = JSON.stringify(tupian1)
                                // }
                                // if (wenjian.length == 0) {
                                //     data.operatingAssets.file = '[]'
                                // } else {
                                //     data.operatingAssets.file = JSON.stringify(wenjian)
                                // }

                                if (data.address !== "" && data.townId !== "" && data.footprint !== "" && data.introduction !== "" && data.name !== "" && data.population !== "") {
                                    console.log(tupian1)
                                    console.log(data)
                                    $.ajax({
                                        url: url + "assets/update",
                                        method: "post",
                                        traditional: true, //防止深度序列化
                                        data: data,
                                        headers: {
                                            "Content-type": "application/json"
                                        },
                                        success: function(data) {
                                            console.log(data)
                                            if (data.code === 200) {
                                                layer.closeAll();
                                                table.reload("idTest", option);
                                                layer.msg('修改成功!')
                                            } else {
                                                layer.msg(data.msg)
                                            }
                                            tupian = []
                                        },
                                        error: function(err) {
                                            layer.msg('修改失败!')
                                        },
                                    })
                                }
                                // else {
                                //     layer.msg("请将信息填写完整")
                                // }
                            }
                        })
                    }

                });

            });
        </script>

        <script>
            //添加表格内行内容
            $(document).ready(function() {
                $('.tianjia').click(function() {
                    layer.open({
                        type: 1,
                        title: "资产新增",
                        offset: "auto",
                        area: ['800px', '660px'],
                        content: `
                <div class="layui-tab">
                    <ul class="layui-tab-title">
                        <li class="layui-this">资产名称</li>
                        <li>非经营性资产</li>
                        <li>经营性资产</li>
                    </ul>
                  <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">
                        <div class="juzhong">
                        <form class="layui-form xingzhengcunxinxitianjia" id="assets" lay-filter="assets" action="">
                            <div class="layui-form-item">
                                <label class="layui-form-label">所属区</label>
                                <div class="layui-input-block">
                                    <select id="qu" name="areaId" lay-verify="required" lay-filter="qu">
                                        <option value="">请选择资源所属区</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">所属镇</label>
                                <div class="layui-input-block">
                                    <select id="zhen" name="townId" lay-verify="required" lay-filter="zhen">
                                        <option value="">请选择所属镇</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">所属村</label>
                                <div class="layui-input-block">
                                    <select id="cun" name="villageId" lay-verify="required" lay-filter="cun">
                                        <option value="">请选择所属村</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">所属组</label>
                                <div class="layui-input-block">
                                    <select id="zu" name="groupId" lay-verify="required" lay-filter="zu">
                                        <option value="">请选择所属组</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">资产类型</label>
                                <div class="layui-input-block">
                                    <select id="zichanleixing" name="typeId" lay-verify="required" lay-filter="zu">
                                        <option value="">请选择资产类型</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">名称</label>
                                <div class="layui-input-block">
                                    <input type="text" lay-filter="ziyuanxinxi" name="name" required lay-verify="required" placeholder="请输入资产名称" autocomplete="off" class="layui-input">
                                </div>
                            </div>                                                 
                        </form>
                        </div>
                    </div>

                    <div class="layui-tab-item">
                    <form class="layui-form xingzhengcunxinxitianjia" id="nonOperatingAssets" lay-filter="nonOperatingAssets" action="">
                        <div class="layui-container">  
                        <div class="layui-row">
                          <div class="layui-col-xs6  layui-col-md6">
                            <div class="layui-form-item">
                            <label class="layui-form-label">计量单位</label>
                            <div class="layui-input-block">
                              <input type="text" name="unitOfMeasurement" required  lay-verify="required" autocomplete="off" class="layui-input" style="width:275px;">
                            </div>
                            </div>
                          </div>
                          <div class="layui-col-xs6  layui-col-md6">
                            <div class="layui-form-item" style="margin-left:-200px;">
                            <label class="layui-form-label">数量</label>
                            <div class="layui-input-block">
                              <input type="number" name="quantity" required  lay-verify="required" autocomplete="off" class="layui-input" style="width:275px;">
                            </div>
                            </div>
                          </div>
                           <div class="layui-col-xs6 layui-col-md6">
                            <div class="layui-form-item">
                            <label class="layui-form-label">单价</label>
                            <div class="layui-input-block">
                              <input type="number" name="unitPrice" required  lay-verify="required" autocomplete="off" class="layui-input" style="width:275px;">
                            </div>
                            </div>
                          </div>
                          <div class="layui-col-xs6 layui-col-md6">
                            <div class="layui-form-item" style="margin-left:-200px;">
                            <label class="layui-form-label">变动情况</label>
                            <div class="layui-input-block">
                              <input type="text" name="changes" required  lay-verify="required" autocomplete="off" class="layui-input" style="width:275px;">
                            </div>
                            </div>
                          </div>
                           <div class="layui-col-xs6 layui-col-md6">
                            <div class="layui-form-item" >
                            <label class="layui-form-label">现今价值</label>
                            <div class="layui-input-block">
                              <input type="number" name="presentValue" required  lay-verify="required" autocomplete="off" class="layui-input" style="width:275px;">
                            </div>
                            </div>
                          </div>
                          <div class="layui-col-xs6 layui-col-md6">
                            <div class="layui-form-item" style="margin-left:-200px;">
                            <label class="layui-form-label">品牌</label>
                            <div class="layui-input-block">
                              <input type="text" name="brand" required  lay-verify="required" autocomplete="off" class="layui-input" style="width:275px;">
                            </div>
                            </div>
                          </div>
                           <div class="layui-col-xs6 layui-col-md6">
                            <div class="layui-form-item">
                            <label class="layui-form-label">规格型号</label>
                            <div class="layui-input-block">
                              <input type="text" name="sizeAndModel" required  lay-verify="required" autocomplete="off" class="layui-input" style="width:275px;">
                            </div>
                            </div>
                          </div>
                          <div class="layui-col-xs6 layui-col-md6">
                            <div class="layui-form-item" style="margin-left:-200px;">
                            <label class="layui-form-label">构建时间</label>
                            <div class="layui-input-block">
                              <input type="text" name="creationTime" id="jianshijian" required  lay-verify="required" autocomplete="off" class="layui-input" style="width:275px;">
                            </div>
                            </div>
                          </div>
                           <div class="layui-col-xs6 layui-col-md6">
                            <div class="layui-form-item">
                            <label class="layui-form-label">产品来源</label>
                            <div class="layui-input-block">
                              <input type="text" name="source" required  lay-verify="required" autocomplete="off" class="layui-input" style="width:275px;">
                            </div>
                            </div>
                          </div>
                          <div class="layui-col-xs6  layui-col-md6">
                            <div class="layui-form-item" style="margin-left:-200px;">
                            <label class="layui-form-label">预计年限</label>
                            <div class="layui-input-block">
                              <input type="text" name="estimatedYears" required  lay-verify="required" autocomplete="off" class="layui-input" style="width:275px;">
                            </div>
                            </div>
                          </div>
                           <div class="layui-col-xs6 layui-col-md6">
                            <div class="layui-form-item">
                            <label class="layui-form-label">使用部门</label>
                            <div class="layui-input-block">
                              <input type="text" name="useDepartmentsAndUser" required  lay-verify="required" autocomplete="off" class="layui-input" style="width:275px;">
                            </div>
                            </div>
                          </div>
                          <div class="layui-col-xs6 layui-col-md6">
                            <div class="layui-form-item" style="margin-left:-200px;">
                            <label class="layui-form-label">产品状态</label>
                            <div class="layui-input-block">
                              <input type="text" name="productStatus" required  lay-verify="required" autocomplete="off" class="layui-input" style="width:275px;">
                            </div>
                            </div>
                          </div>
                          <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">备注</label>
                            <div class="layui-input-block">
                              <textarea name="remarks" placeholder="请输入备注信息" class="layui-textarea beizhu" style="width:275px;"></textarea>
                            </div>
                          </div>
                        </div>
                        </div>
                        </form>
                    </div>

                    <div class="layui-tab-item">
                        <form class="layui-form xingzhengcunxinxitianjia" id="operatingAssets" lay-filter="operatingAssets" action="">
                        <div class="layui-container">  
                        <div class="layui-row">
                          <div class="layui-col-xs6  layui-col-md6">
                            <div class="layui-form-item">
                            <label class="layui-form-label">承租方</label>
                            <div class="layui-input-block">
                              <input type="text" name="lessee" required  lay-verify="required" autocomplete="off" class="layui-input" style="width:275px;">
                            </div>
                            </div>
                          </div>
                          <div class="layui-col-xs6  layui-col-md6">
                            <div class="layui-form-item" style="margin-left:-200px;">
                            <label class="layui-form-label">签订合同</label>
                            <div class="layui-input-block">
                              <select name="contractSigned" lay-verify="required">
                                <option value="">请选择是否签订合同</option>
                                <option value="0">是</option>
                                <option value="1">否</option>
                              </select>
                            </div>
                            </div>
                          </div>
                           <div class="layui-col-xs6 layui-col-md6">
                            <div class="layui-form-item">
                            <label class="layui-form-label">合同期限</label>
                            <div class="layui-input-block">
                              <input type="text" name="durationOfCooperation" required  lay-verify="required" autocomplete="off" class="layui-input" style="width:275px;">
                            </div>
                            </div>
                          </div>
                          <div class="layui-col-xs6 layui-col-md6">
                            <div class="layui-form-item" style="margin-left:-200px;">
                            <label class="layui-form-label">支付情况</label>
                            <div class="layui-input-block">
                              <input type="text" name="paymentStatus" required  lay-verify="required" autocomplete="off" class="layui-input" style="width:275px;">
                            </div>
                            </div>
                          </div>
                           <div class="layui-col-xs6 layui-col-md6">
                            <div class="layui-form-item">
                            <label class="layui-form-label">合同状态</label>
                            <div class="layui-input-block">
                              <input type="text" name="contractStatus" required  lay-verify="required" autocomplete="off" class="layui-input" style="width:275px;">
                            </div>
                            </div>
                          </div>
                          <div class="layui-col-xs6 layui-col-md6">
                            <div class="layui-form-item" style="margin-left:-200px;">
                            <label class="layui-form-label">合同金额</label>
                            <div class="layui-input-block">
                              <input type="text" name="amount" required  lay-verify="required" autocomplete="off" class="layui-input" style="width:275px;">
                            </div>
                            </div>
                          </div>                                                         
                          <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">备注</label>
                            <div class="layui-input-block">
                              <textarea name="remarks" placeholder="请输入备注信息" class="layui-textarea beizhu" style="width:275px;"></textarea>
                            </div>
                          </div>
                          <div class="layui-form-item" style="display:none;">
                            <label class="layui-form-label">图片</label>
                            <div class="layui-input-block">
                                <div class="layui-upload" name="">
                                    <div class="layui-upload" name="">
                                        <button type="button" class="layui-btn" id="shangchuantupian">图片选择</button>
                                        <button type="button" class="layui-btn" id="shangchuananniu">图片上传</button>
                                        <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                            预览图：
                                            <div class="layui-upload-list" id="tupianyuelan"></div>
                                        </blockquote>
                                    </div>
                                </div>
                            </div>
                          </div>
                            <div class="layui-form-item" style="display:none;">
                                <label class="layui-form-label">相关文件</label>
                                <div class="layui-input-block">
                                    <div class="layui-upload-drag" id="test10">
                                        <i class="layui-icon"></i>
                                        <p>点击上传，或将文件拖拽到此处</p>
                                        <div class="layui-hide" id="uploadDemoView">
                                            <hr>
                                            <p/>
                                        </div>
                                    </div>
                                    <button type="button" class="layui-btn" id="testListActio">点击上传</button>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button type="button" class="layui-btn layui-btn-normal bianji" id="tianjia">添加</button>
                                </div>
                            </div> 
                        </div>
                        </div>
                        </form>
                    </div>
                  </div>
                </div>
                `,
                        success: function() {
                            areas.forEach(item => {
                                $('#qu')[0].innerHTML += ` <option value="` + item.id + `">` + item.name + `</option>`
                            })
                            towns.forEach(item => {
                                $('#zhen')[0].innerHTML += ` <option value="` + item.id + `">` + item.name + `</option>`
                            })


                            // 监听每一个选择框的选择事件
                            var tianjiaqu = ""
                                // 1.区选择
                            form.on('select(qu)', function(data) {
                                tianjiaqu = data.value;
                                $('#zhen').empty()
                                $('#zhen')[0].innerHTML += ` <option value="">请选择所属镇</option>`
                                towns.forEach(item => {
                                    s
                                    if (item.areaId == data.value) {
                                        $('#zhen')[0].innerHTML += ` <option value="` + item.id + `">` + item.name + `</option>`
                                    }
                                })
                                form.render('select', "assets")
                            });
                            // 2.镇监听
                            form.on('select(zhen)', function(data) {
                                $('#cun').empty()
                                $('#cun')[0].innerHTML += ` <option value="">请选择所属村</option>`
                                villages.forEach(item => {
                                    if (item.townId == data.value) {
                                        $('#cun')[0].innerHTML += ` <option value="` + item.id + `">` + item.name + `</option>`
                                    }
                                })
                                form.render('select', "assets")
                            });

                            // 村监听
                            form.on('select(cun)', function(data) {
                                console.log(data.value)
                                $('#zu').empty()
                                $('#zu')[0].innerHTML += ` <option value="">请选择所属组</option>`

                                if (data.value != "") {
                                    var data1 = {}
                                    console.log(getvillage(data.value))
                                    data1.areaId = tianjiaqu
                                    data1.townId = getvillage(data.value).townId
                                    data1.villageId = data.value
                                    console.log(data1)
                                    $.ajax({
                                        url: url + "group/querygroup",
                                        method: "get",
                                        data: data1,
                                        success: function(data) {
                                            console.log(data)
                                            data.data.group.forEach(item => {
                                                $('#zu')[0].innerHTML += ` <option value="` + item.id + `">` + item.name + `</option>`
                                            })
                                            form.render('select', "assets")
                                        },
                                        error: function(err) {
                                            console.log(err)
                                        }
                                    })
                                    $.ajax({
                                        url: url + "assetstype/query",
                                        method: "post",
                                        data: data1,
                                        success: function(data) {
                                            console.log(data)
                                            data.data.AssetsTypeList.forEach(item => {
                                                $('#zichanleixing')[0].innerHTML += ` <option value="` + item.id + `">` + item.name + `</option>`
                                            })
                                            form.render('select', "assets")
                                        },
                                        error: function(err) {
                                            console.log(err)
                                        }
                                    })
                                }
                                form.render('select', "assets")
                            })
                            form.render('select', "assets")
                            form.render('select', "operatingAssets")
                            laydate.render({
                                elem: '#jianshijian' //指定元素
                            });
                            // 上传图片的
                            // upload.render({
                            //     elem: '#shangchuantupian',
                            //     url: url + 'upload',
                            //     name: "files",
                            //     data: {
                            //         folderName: "ZiChanJingYing"
                            //     },
                            //     headers: {
                            //         token: localStorage.getItem('token')
                            //     },
                            //     field: "multipartFiles",
                            //     auto: false,
                            //     bindAction: "#shangchuananniu",
                            //     multiple: true,
                            //     before: function(obj) { //obj参数包含的信息，跟 choose回调完全一致，可参见上文。
                            //         loading2 = layer.load(); //换了种风格
                            //     },
                            //     allDone: function(obj) { //当文件全部被提交后，才触发
                            //         layer.close(loading2);
                            //         layer.msg('上传成功')
                            //     },
                            //     choose: function(obj) {
                            //         var files = obj.pushFile();
                            //         console.log(files)
                            //         console.log(obj)
                            //             //预读本地文件示例，不支持ie8
                            //         obj.preview(function(index, file, result) {
                            //             tupian.push(file)
                            //             $('#tupianyuelan').append('<img src="' + result + '" alt="' + file.name + '" class="layui-upload-img">')
                            //         });
                            //     },
                            //     done: function(res, index, upload) {
                            //         res.data = JSON.parse(res.data)
                            //         console.log(res)
                            //         if (res.code === 200) {
                            //             res.data.forEach(item => {
                            //                 tupian1.push({
                            //                     name: item.name,
                            //                     url: item.url
                            //                 })
                            //             })
                            //         }
                            //     },
                            //     error: function(index, upload) {
                            //         layer.msg("上传失败")
                            //             //当上传失败时，你可以生成一个“重新上传”的按钮，点击该按钮时，执行 upload() 方法即可实现重新上传
                            //     },

                            // })

                            //拖拽上传
                            // upload.render({
                            //     elem: '#test10',
                            //     url: url + 'upload', //改成您自己的上传接口
                            //     accept: 'file',
                            //     auto: false,
                            //     field: "multipartFiles",
                            //     bindAction: '#testListActio',
                            //     before: function(obj) { //obj参数包含的信息，跟 choose回调完全一致，可参见上文。
                            //         loading2 = layer.load(); //换了种风格
                            //     },
                            //     choose: function(res) {
                            //         res.preview(function(index, file, result) {
                            //             layui.$('#test10').find('p')[0].innerHTML = "点击更换"
                            //             layui.$('#uploadDemoView').removeClass('layui-hide').find('p')[0].innerHTML = file.name
                            //         });
                            //     },
                            //     done: function(res, index, upload) {
                            //         layer.close(loading2);
                            //         res.data = JSON.parse(res.data)
                            //         console.log(res)
                            //         if (res.code === 200) {
                            //             wenjian = res.data
                            //             layer.msg('上传成功')
                            //         } else {
                            //             layer.msg('上传失败')
                            //         }
                            //     }
                            // });

                            //btn: ['添加', ], //可以无限个按钮
                            btnAlign: "c",

                                $("#tianjia").click(function() {
                                    var data = {}
                                    data.assets = form.val("assets");
                                    data.nonOperatingAssets = form.val("nonOperatingAssets");
                                    data.operatingAssets = form.val("operatingAssets");
                                    data = JSON.stringify(data)


                                    // if (tupian1.length !== 0) {
                                    //     data.operatingAssets.relatedDocuments = JSON.stringify(tupian1)
                                    // }
                                    // if (wenjian.length == 0) {
                                    //     data.operatingAssets.file = '[]'
                                    // } else {
                                    //     data.operatingAssets.file = JSON.stringify(wenjian)
                                    // }
                                    console.log(data)
                                    $.ajax({
                                        url: url + "assets/add",
                                        method: "post",
                                        traditional: true, //防止深度序列化
                                        data: data,
                                        headers: {
                                            "Content-type": "application/json"
                                        },
                                        success: function(data) {
                                            console.log(data)
                                            if (data.code === 200) {
                                                layer.closeAll();
                                                table.reload("idTest", option);
                                                layer.msg('添加成功!')
                                            } else {
                                                layer.msg(data.msg)
                                            }
                                            tupian = []
                                            tupian1 = []
                                        },
                                        error: function(err) {
                                            layer.msg('添加失败!')
                                        },
                                    })
                                })
                        }
                    });
                })
            });
        </script>

        <script>
            $(document).ready(function() {
                $('.shanchucheck').click(function() {
                    var checkStatus = table.checkStatus("idTest"); //idTest 即为基础参数 id 对应的值
                    console.log(checkStatus.data); //获取选中行的数据
                    var data = {}
                    data.IdList = [];
                    checkStatus.data.forEach((item) => {
                        data.IdList.push(item.assets.id);
                    });
                    console.log(data)
                        // data=JSON.stringify(data)
                        // console.log(data)
                    $.ajax({
                        url: url + "assets/del",
                        method: "post",
                        data: data,
                        traditional: true, //防止深度序列化,
                        // type:"json",
                        success: function(data) {
                            if (data.code === 200) {
                                layer.closeAll();
                                table.reload("idTest", option);
                                layer.msg("删除成功")
                            } else {
                                layer.msg(data.msg)
                            }
                            console.log(data);

                        },
                        error: function(err) {},
                    });
                })
            })
        </script>
        <script>
            //到出选中行
            function daochuxuanzhehang() {
                var checkStatus = table.checkStatus('idTest'); //idTest 即为基础参数 id 对应的值
                console.log(checkStatus.data) //获取选中行的数据
                table.exportFile('idTest', checkStatus.data, 'xls');
            }
            // 去除图片
            function quchutupian(url, e) {
                console.log(url)
                tupian1.forEach((item, index) => {
                    if (item.url == url) {
                        tupian1.splice(index, 1);
                    }
                })
                $('#tupianyuelan')[0].removeChild(e)
                console.log(tupian1)
            }
        </script>
        <script>
            //导入数据
            function setdata(data) {
                console.log(data)
                data.forEach(item => {
                    item.villagename = getvillage(item.assets.villageId).name
                    item.assetsname = item.assets.name
                    item.assetstype = item.assets.name
                })
                console.log(data)
                return data
            }

            // 设置查询刷新列表
            function chaxun() {
                var data = form.val("saixuan");
                console.log(data)
                option.where.areaId = data.areaId
                option.where.townid = data.townid
                option.where.villageId = data.villageId
                option.where.name = data.keyWords
                console.log(option.where)
                table.reload("idTest", option);
                option.where.townid = ""
                option.where.villageId = ''
                option.where.name = ""
            }
        </script>
        <script>
            // 非经营性资产上传信息
            function feijingyingxingzichan() {
                // 文件
                upload.render({
                    elem: '#test1',
                    url: '',
                    multiple: false,
                    method: 'post',
                    accept: 'file',
                    auto: false,
                    bindAction: "#12343213123",
                    headers: {
                        token: localStorage.getItem('token')
                    },
                    before: function(obj) { //obj参数包含的信息，跟 choose回调完全一致，可参见上文。
                        loading2 = layer.load(); //换了种风格
                    },
                    choose: function(obj) {
                        var formData = new FormData();
                        obj.preview(function(index, file, result) {
                            formData.append('file', file)
                            console.log(formData.get('file'))
                            $.ajax({
                                url: url + 'Excel/nonoperatingUpload',
                                method: "post",
                                data: formData,
                                cache: false,
                                contentType: false,
                                processData: false,
                                success: function(data) {
                                    if (data.code === 0) {
                                        layer.msg(data.msg)
                                        table.reload("idTest", option);
                                    } else {
                                        layer.msg(data.msg)
                                    }
                                },
                                error: function(err) {
                                    console.log(err)
                                }
                            })
                        });

                    },
                })
            }


            // 经营性资产上传信息
            function jingyingxingzichan() {
                // 文件
                upload.render({
                    elem: '#test2',
                    url: '',
                    multiple: false,
                    method: 'post',
                    accept: 'file',
                    auto: false,
                    bindAction: "#12343213123",
                    headers: {
                        token: localStorage.getItem('token')
                    },
                    before: function(obj) { //obj参数包含的信息，跟 choose回调完全一致，可参见上文。
                        loading2 = layer.load(); //换了种风格
                    },
                    choose: function(obj) {
                        var formData = new FormData();
                        obj.preview(function(index, file, result) {
                            formData.append('file', file)
                            console.log(formData.get('file'))
                            $.ajax({
                                url: url + 'Excel/operatingUpload',
                                method: "post",
                                data: formData,
                                cache: false,
                                contentType: false,
                                processData: false,
                                success: function(data) {
                                    if (data.code === 0) {
                                        layer.msg(data.msg)
                                        table.reload("idTest", option);
                                    } else {
                                        layer.msg(data.msg)
                                    }
                                },
                                error: function(err) {
                                    console.log(err)
                                }
                            })
                        });

                    },
                })
            }
        </script>
</body>

</html>